﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;
//using CoreEx.Database.Metadata.Generation;
//using LinFu.IoC.Configuration;
//using LinFu.IoC.Interfaces;
//using LinFu.IoC;

//namespace CoreEx.Database.MetaData.Implementation.Generation
//{
//    /// <summary>
//    /// Creates one source file for each <see cref="GeneratedType"/>
//    /// </summary>
//    [Implements(typeof(IModelWriter))]
//    public class ModelWriter : IModelWriter, IInitialize
//    {
//        public IMemberWriter<TypeDescription> TypeWriter { get; set; }
        
        
//        /// <summary>
//        /// Writes the <paramref name="generatedTypes"/> to the <paramref name="outputDirectory"/>
//        /// </summary>
//        /// <param name="generatedTypes">A list of <see cref="GeneratedType"/> instances that will be written to disc.</param>
//        /// <param name="outputDirectory">The directory for which to output the source files.</param>
//        public void WriteModel(IEnumerable<TypeDescription> generatedTypes, string outputDirectory)
//        {
//            foreach (var typeDescription in generatedTypes)
//            {
//                using(TextWriter textWriter = CreateTextWriter(""))
//                {
//                    TypeWriter.Write(typeDescription,textWriter);
//                    textWriter.Flush();
//                }                
//            }
//        }

//        protected virtual bool ShouldWrite(string path)
//        {
//            //Todo do not write if the file is write protected
//            return true;
//        }


//        protected virtual TextWriter CreateTextWriter(string path)
//        {
//            var fileStream = new FileStream(path,FileMode.Create,FileAccess.Write);
//            var streamWriter = new StreamWriter(fileStream);
//            return streamWriter;
//        }


//        public void Initialize(IServiceContainer source)
//        {
//            TypeWriter = source.GetService<IMemberWriter<TypeDescription>>();
//        }
//    }
//}
